<admintpl file="header" />
<style>
	*{margin:0; padding:0;}
	body{font-family: "Microsoft Yahei", "hiragino sans gb", Helvetica, Arial, Tahoma;}
	.shdo{position: fixed; left:0; top:0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 10; display: none;}
	.stan-box{padding:10px 20px; width: 400px; max-height: 500px; background: #fff; position: fixed; left:100px; top:100px; z-index: 11; display: none;}
	.simgBox{max-height: 440px; overflow: auto; text-align: center;}
	.simgBox img{}
	.stit{height: 30px;}
	.stit .yuan{font-size: 14px;}
	.stit .cuo{display: block; width: 20px; height: 20px; color: #fff; background: #007aff; line-height: 20px; text-align: center; position: absolute; right:0; top:0; cursor: pointer;}
	.sbot{height: 30px; }
	.sbot span{height: 26px; line-height: 26px; width: 50px; font-size: 12px; color: #fff;  background: #007aff;  float: right; text-align: center; border-radius: 2px;margin-top: 6px; cursor: pointer;}
	.tanimg{cursor:pointer;}
</style>
</head>
<body>
<div class="wrap">
	<ul class="nav nav-tabs">
		<li class="active"><a>银行卡账户</a></li>
	</ul>
	<!--<form class="well form-search" method="post" id="forms" action="{:U('Order/pay_record')}">-->

	<!--</form>-->
	<form method="post" class="js-ajax-form">
		<table class="table table-hover table-bordered" style="width: 600px">
			<thead>
			<tr>
				<th style="text-align: center">等级</th>
				<th style="text-align: center">开户银行</th>
				<th style="text-align: center">开户支行</th>
				<th style="text-align: center">账户姓名</th>
				<th style="text-align: center">银行卡号</th>
				<th style="text-align: center">操作</th>
			</tr>
			</thead>
			<foreach name="data" item="v">
				<tr>
					<td style="text-align: center">{$v.dengji}</td>
					<td style="text-align: center">{$v['yinhang']}</td>
					<td style="text-align: center">{$v.zhihang}</td>
					<td style="text-align: center">{$v.name}</td>
					<td style="text-align: center">{$v.number}</td>
					<td style="text-align: center">
						<a href="{:U('Order/bankcard_upd',array('dengji'=>$v['dengji']))}">修改</a>  |
						<a href="{:U('Order/bankcard_del',array('id'=>$v['id']))}">删除</a>
					</td>
				</tr>
			</foreach>
		</table><br/>
	</form>
		<form action="{:U('Order/bankcard_add')}" enctype="multipart/form-data" method="post" id="form">
			<div>
				<span style="margin-left: 20px">等&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;级:</span>
				<select style="width: 80px;height: 30px" name="dengji" class="dengji">
					<option value="1">VIP1</option>
					<option value="2">VIP2</option>
					<option value="3">VIP3</option>
					<option value="4">VIP4</option>
					<option value="5">VIP5</option>
					<option value="6">VIP6</option>
					<option value="7">VIP7</option>
					<option value="8">VIP8</option>
					<option value="9">VIP9</option>
				</select><br/>
				<span style="margin-left: 20px">开户银行:</span>
				<input type="text" name="yinhang"><br>

				<span style="margin-left: 20px">账户姓名:</span>
				<input type="text" name="name" class="name" style="margin-left: 5px;width: 100px;height: 16px" placeholder="请输入账户姓名"><br/>
				<span style="margin-left: 20px">卡&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号:</span>
				<input type="text" name="yinhangka" class="kahao1" style="margin-left: 5px;width: 170px;margin-right: 50px;height: 16px" placeholder="请输入账户卡号"><br/>
				<span style="margin-left: 20px">确认卡号:</span>
				<input type="text" name="yinhangka" class="kahao2" style="margin-left: 5px;width: 170px;margin-right: 50px;height: 16px"placeholder="请再次输入卡号"><br/>
				<span style="margin-left: 20px">开户支行:</span>
				<input type="text" name="zhihang" class="zhihang" style="margin-left: 5px;width: 170px;margin-right: 50px;height: 16px"placeholder="请输入开户支行"><br/>
                <input class="btn btn-danger" type="button" value="添加" onclick="sav()" style="margin-left: 120px;margin-top: 30px">

			</div>

	</form>
<script src="__PUBLIC__/js/common.js"></script>
</div>
</body>
</html>
<script>
	function sav(){
		var kahao1 = $(".kahao1").val();
		var kahao2 = $(".kahao2").val();
		var name1 = $(".name").val();
		var name = name1.replace(/\s+/g,"");
		var zhihang = $(".zhihang").val();
		var yinhang = $(".yinhang").val();
		if(yinhang == ''){
			alert("开户银行不能为空");
			return false;
		}
		if(name == ''){
			alert("账户姓名不能为空");
			return false;
		}
		if(zhihang == ''){
			alert("开户支行不能为空");
			return false;
		}

      // 账户姓名必须是汉字
		if(!/^[\u4e00-\u9fa5]+$/gi.test(name)){
          alert("账户姓名必须为汉字");
			return false
		}
		if(name.length>5 || name.length<2){
			alert("账户姓名在两个汉字-五个汉字之间");
			return false;
		}


		if(kahao1 == ''){
			alert("银行卡号不能为空");
			return false;
		}
		if(kahao1.length < 16 || kahao1.length > 19) {
			alert("银行卡号长度必须在16到19之间");
			return false;
		}
		var num = /^\d*$/; //全数字
		if(!num.exec(kahao1)) {
			alert("银行卡号必须全为数字");
			return false;
		}
		//开头6位
		var strBin = "10,18,30,35,37,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,60,62,65,68,69,84,87,88,94,95,98,99";
		if(strBin.indexOf(kahao1.substring(0, 2)) == -1) {
			alert("银行卡号开头6位不符合规范");
			return false;
		}
		if(kahao2 == ''){
			alert("确认卡号不能为空");
			return false;
		}
		if(kahao2 != kahao1){
			alert("两次输入的卡号不正确");
			return false;
		}
	  $("#form").submit();
	}
</script>